"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
    return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
var vue_1 = require("vue");
var icons_vue_1 = require("@ant-design/icons-vue");
var vue_router_1 = require("vue-router");
var useLoginUserStore_1 = require("@/stores/useLoginUserStore");
var userController_1 = require("@/api/userController");
var ant_design_vue_1 = require("ant-design-vue");
var icons_vue_2 = require("@ant-design/icons-vue");
var loginUserStore = (0, useLoginUserStore_1.useLoginUserStore)();
var router = (0, vue_router_1.useRouter)();
var current = (0, vue_1.ref)(['/']);
var originItems = (0, vue_1.ref)([
    {
        key: '/',
        icon: function () { return (0, vue_1.h)(icons_vue_1.HomeOutlined); },
        label: '主页',
        title: '主页',
    },
    {
        key: '/admin/userManage',
        label: '用户管理',
        title: '用户管理',
    },
    {
        key: 'others',
        label: (0, vue_1.h)('a', { href: 'https://www.comfred.cn', target: '_blank' }, 'compass'),
        title: 'compass',
    },
    {
        key: '/add_picture',
        label: '创建图片',
        title: '创建图片',
    },
    {
        key: '/admin/pictureManage',
        label: '图片管理',
        title: '图片管理',
    },
    {
        key: '/admin/spaceManage',
        label: '空间管理',
        title: '空间管理',
    },
]);
// 定义方法
var doMenuClick = function (_a) {
    var key = _a.key;
    router.push({
        path: key,
    });
};
// 后置路由
router.afterEach(function (to, from, next) {
    current.value = [to.path];
});
// 用户注销
var doLogout = function () { return __awaiter(void 0, void 0, void 0, function () {
    var res;
    return __generator(this, function (_a) {
        switch (_a.label) {
            case 0: return [4 /*yield*/, (0, userController_1.userLogoutUsingPost)()];
            case 1:
                res = _a.sent();
                if (!(res.data.code === 0)) return [3 /*break*/, 3];
                loginUserStore.setLoginUser({
                    userName: '未登录',
                });
                ant_design_vue_1.message.success('退出登录成功');
                return [4 /*yield*/, router.push('/user/login')];
            case 2:
                _a.sent();
                return [3 /*break*/, 4];
            case 3:
                ant_design_vue_1.message.error('退出登录失败，' + res.data.message);
                _a.label = 4;
            case 4: return [2 /*return*/];
        }
    });
}); };
// 编写过滤菜单项，根据用户决定展示内容
// 过滤菜单项
var filterMenus = function (menus) {
    if (menus === void 0) { menus = []; }
    // console.log('menus:',menus.value);
    return menus.value.filter(function (menu) {
        var _a;
        if ((_a = menu.key) === null || _a === void 0 ? void 0 : _a.startsWith('/admin')) {
            var loginUser = loginUserStore.loginUser;
            if (!loginUser || (loginUser === null || loginUser === void 0 ? void 0 : loginUser.userRole) !== "admin") {
                return false;
            }
        }
        return true;
    });
};
// 展示在菜单的路由数组
var items = (0, vue_1.computed)(function () { return filterMenus(originItems); }); /* PartiallyEnd: #3632/scriptSetup.vue */
function __VLS_template() {
    var _a;
    var __VLS_ctx = {};
    var __VLS_components;
    var __VLS_directives;
    // CSS variable injection 
    // CSS variable injection end 
    __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)(__assign({ class: ("globalHeader") }));
    var __VLS_0 = {}.ARow;
    /** @type { [typeof __VLS_components.ARow, typeof __VLS_components.aRow, typeof __VLS_components.ARow, typeof __VLS_components.aRow, ] } */ ;
    // @ts-ignore
    var __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0({
        wrap: ((false)),
    }));
    var __VLS_2 = __VLS_1.apply(void 0, __spreadArray([{
            wrap: ((false)),
        }], __VLS_functionalComponentArgsRest(__VLS_1), false));
    var __VLS_6 = {}.ACol;
    /** @type { [typeof __VLS_components.ACol, typeof __VLS_components.aCol, typeof __VLS_components.ACol, typeof __VLS_components.aCol, ] } */ ;
    // @ts-ignore
    var __VLS_7 = __VLS_asFunctionalComponent(__VLS_6, new __VLS_6({
        flex: ("200px"),
    }));
    var __VLS_8 = __VLS_7.apply(void 0, __spreadArray([{
            flex: ("200px"),
        }], __VLS_functionalComponentArgsRest(__VLS_7), false));
    var __VLS_12 = {}.RouterLink;
    /** @type { [typeof __VLS_components.RouterLink, typeof __VLS_components.RouterLink, ] } */ ;
    // @ts-ignore
    var __VLS_13 = __VLS_asFunctionalComponent(__VLS_12, new __VLS_12({
        to: ("/"),
    }));
    var __VLS_14 = __VLS_13.apply(void 0, __spreadArray([{
            to: ("/"),
        }], __VLS_functionalComponentArgsRest(__VLS_13), false));
    __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)(__assign({ class: ("title-bar") }));
    __VLS_elementAsFunction(__VLS_intrinsicElements.img)(__assign({ class: ("logo") }, { src: ("../assets/logo.jpg"), alt: ("logo") }));
    __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)(__assign({ class: ("title") }));
    __VLS_17.slots.default;
    var __VLS_17;
    __VLS_11.slots.default;
    var __VLS_11;
    var __VLS_18 = {}.ACol;
    /** @type { [typeof __VLS_components.ACol, typeof __VLS_components.aCol, typeof __VLS_components.ACol, typeof __VLS_components.aCol, ] } */ ;
    // @ts-ignore
    var __VLS_19 = __VLS_asFunctionalComponent(__VLS_18, new __VLS_18({
        flex: ("auto"),
    }));
    var __VLS_20 = __VLS_19.apply(void 0, __spreadArray([{
            flex: ("auto"),
        }], __VLS_functionalComponentArgsRest(__VLS_19), false));
    var __VLS_24 = {}.AMenu;
    /** @type { [typeof __VLS_components.AMenu, typeof __VLS_components.aMenu, ] } */ ;
    // @ts-ignore
    var __VLS_25 = __VLS_asFunctionalComponent(__VLS_24, new __VLS_24(__assign({ 'onClick': {} }, { selectedKeys: ((__VLS_ctx.current)), mode: ("horizontal"), items: ((__VLS_ctx.items)) })));
    var __VLS_26 = __VLS_25.apply(void 0, __spreadArray([__assign({ 'onClick': {} }, { selectedKeys: ((__VLS_ctx.current)), mode: ("horizontal"), items: ((__VLS_ctx.items)) })], __VLS_functionalComponentArgsRest(__VLS_25), false));
    var __VLS_30;
    var __VLS_31 = {
        onClick: (__VLS_ctx.doMenuClick)
    };
    var __VLS_27;
    var __VLS_28;
    var __VLS_29;
    __VLS_23.slots.default;
    var __VLS_23;
    __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)(__assign({ class: ("user-login-status") }));
    if (__VLS_ctx.loginUserStore.loginUser.id) {
        __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({});
        var __VLS_32 = {}.ADropdown;
        /** @type { [typeof __VLS_components.ADropdown, typeof __VLS_components.aDropdown, typeof __VLS_components.ADropdown, typeof __VLS_components.aDropdown, ] } */ ;
        // @ts-ignore
        var __VLS_33 = __VLS_asFunctionalComponent(__VLS_32, new __VLS_32({}));
        var __VLS_34 = __VLS_33.apply(void 0, __spreadArray([{}], __VLS_functionalComponentArgsRest(__VLS_33), false));
        var __VLS_38 = {}.ASpace;
        /** @type { [typeof __VLS_components.ASpace, typeof __VLS_components.ASpace, ] } */ ;
        // @ts-ignore
        var __VLS_39 = __VLS_asFunctionalComponent(__VLS_38, new __VLS_38({}));
        var __VLS_40 = __VLS_39.apply(void 0, __spreadArray([{}], __VLS_functionalComponentArgsRest(__VLS_39), false));
        var __VLS_44 = {}.AAvatar;
        /** @type { [typeof __VLS_components.AAvatar, typeof __VLS_components.aAvatar, typeof __VLS_components.AAvatar, typeof __VLS_components.aAvatar, ] } */ ;
        // @ts-ignore
        var __VLS_45 = __VLS_asFunctionalComponent(__VLS_44, new __VLS_44(__assign({ style: ({}) }, { shape: ("square"), size: ("large"), src: ((__VLS_ctx.loginUserStore.loginUser.userAvatar)) })));
        var __VLS_46 = __VLS_45.apply(void 0, __spreadArray([__assign({ style: ({}) }, { shape: ("square"), size: ("large"), src: ((__VLS_ctx.loginUserStore.loginUser.userAvatar)) })], __VLS_functionalComponentArgsRest(__VLS_45), false));
        __VLS_elementAsFunction(__VLS_intrinsicElements.template, __VLS_intrinsicElements.template)({});
        {
            var __VLS_thisSlot = __VLS_49.slots.icon;
            var __VLS_50 = {}.UserOutlined;
            /** @type { [typeof __VLS_components.UserOutlined, ] } */ ;
            // @ts-ignore
            var __VLS_51 = __VLS_asFunctionalComponent(__VLS_50, new __VLS_50({}));
            var __VLS_52 = __VLS_51.apply(void 0, __spreadArray([{}], __VLS_functionalComponentArgsRest(__VLS_51), false));
        }
        var __VLS_49;
        ((_a = __VLS_ctx.loginUserStore.loginUser.userName) !== null && _a !== void 0 ? _a : '无名');
        __VLS_43.slots.default;
        var __VLS_43;
        __VLS_elementAsFunction(__VLS_intrinsicElements.template, __VLS_intrinsicElements.template)({});
        {
            var __VLS_thisSlot = __VLS_37.slots.overlay;
            var __VLS_56 = {}.AMenu;
            /** @type { [typeof __VLS_components.AMenu, typeof __VLS_components.aMenu, typeof __VLS_components.AMenu, typeof __VLS_components.aMenu, ] } */ ;
            // @ts-ignore
            var __VLS_57 = __VLS_asFunctionalComponent(__VLS_56, new __VLS_56({}));
            var __VLS_58 = __VLS_57.apply(void 0, __spreadArray([{}], __VLS_functionalComponentArgsRest(__VLS_57), false));
            var __VLS_62 = {}.AMenuItem;
            /** @type { [typeof __VLS_components.AMenuItem, typeof __VLS_components.aMenuItem, typeof __VLS_components.AMenuItem, typeof __VLS_components.aMenuItem, ] } */ ;
            // @ts-ignore
            var __VLS_63 = __VLS_asFunctionalComponent(__VLS_62, new __VLS_62(__assign({ 'onClick': {} })));
            var __VLS_64 = __VLS_63.apply(void 0, __spreadArray([__assign({ 'onClick': {} })], __VLS_functionalComponentArgsRest(__VLS_63), false));
            var __VLS_68 = void 0;
            var __VLS_69 = {
                onClick: (__VLS_ctx.doLogout)
            };
            var __VLS_65 = void 0;
            var __VLS_66 = void 0;
            var __VLS_70 = {}.LogoutOutlined;
            /** @type { [typeof __VLS_components.LogoutOutlined, ] } */ ;
            // @ts-ignore
            var __VLS_71 = __VLS_asFunctionalComponent(__VLS_70, new __VLS_70({}));
            var __VLS_72 = __VLS_71.apply(void 0, __spreadArray([{}], __VLS_functionalComponentArgsRest(__VLS_71), false));
            __VLS_67.slots.default;
            var __VLS_67;
            __VLS_61.slots.default;
            var __VLS_61;
        }
        var __VLS_37;
    }
    else {
        __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({});
        var __VLS_76 = {}.AButton;
        /** @type { [typeof __VLS_components.AButton, typeof __VLS_components.aButton, typeof __VLS_components.AButton, typeof __VLS_components.aButton, ] } */ ;
        // @ts-ignore
        var __VLS_77 = __VLS_asFunctionalComponent(__VLS_76, new __VLS_76({
            type: ("primary"),
            href: ("/user/login"),
        }));
        var __VLS_78 = __VLS_77.apply(void 0, __spreadArray([{
                type: ("primary"),
                href: ("/user/login"),
            }], __VLS_functionalComponentArgsRest(__VLS_77), false));
        __VLS_81.slots.default;
        var __VLS_81;
    }
    __VLS_5.slots.default;
    var __VLS_5;
    ['globalHeader', 'title-bar', 'logo', 'title', 'user-login-status',];
    var __VLS_slots;
    var $slots;
    var __VLS_inheritedAttrs;
    var $attrs;
    var __VLS_refs = {};
    var $refs;
    var $el;
    return {
        attrs: {},
        slots: __VLS_slots,
        refs: $refs,
        rootEl: $el,
    };
}
;
var __VLS_self = (await Promise.resolve().then(function () { return __importStar(require('vue')); })).defineComponent({
    setup: function () {
        return {
            LogoutOutlined: icons_vue_1.LogoutOutlined,
            UserOutlined: icons_vue_2.UserOutlined,
            loginUserStore: loginUserStore,
            current: current,
            doMenuClick: doMenuClick,
            doLogout: doLogout,
            items: items,
        };
    },
});
exports.default = (await Promise.resolve().then(function () { return __importStar(require('vue')); })).defineComponent({
    setup: function () {
        return {};
    },
    __typeEl: {},
});
; /* PartiallyEnd: #4569/main.vue */
